iT邦幫忙

2024 iThome 鐵人賽

DAY 5
0
Software Development

數位醫療與雲原生第一次的親密接觸系列 第 5

Day 5 [數位醫療]FHIR Sever API使用

  • 分享至 

  • xImage
  •  

FHIR Server API有許多特別的規則及識別符,可以透過添加不同的識別符進行複雜的檢索查詢,簡單來說就是不用再寫複雜到爆的子查詢來拉資料啦!!!真是可喜可賀。今天會介紹這些規則及識別符的應用,媽媽再也不擔心我寫不出SQL查詢語句啦!!!

獲取所有的測量數據

{prefix}/fhir/Observation

註:測試環境的prefix為 http://127.0.0.1:8080,以獲取所有的測量數據為例,完整的API為 http://127.0.0.1:8080/fhir/Observation

獲取patient id 23所有的測量數據

HTTP Method : GET

{prefix}/fhir/Observation?subject=Patient/23
{prefix}/fhir/Observation?subject:Patient/23
{prefix}/fhir/Observation?patient=23

以上三種寫法都能拿到patient id 23所有的測量數據

獲取patient id 23一段時間內所有的數據

{prefix}/fhir/Observation?patient=23&_lastUpdated=eq{日期}
  • eq : 等於
  • gt : 大於
  • ge : 大於或等於
  • lt : 小於
  • le : 小於或等於

範例

獲取patient id 23於2024-09-01當天的檢測數據

{prefix}/fhir/Observation?patient=23&_lastUpdated=eq2024-09-01

獲取patient id 23於2024-09-01前的檢測數據

{prefix}/fhir/Observation?patient=23&_lastUpdated=lt2024-09-01

獲取patient id 23於2024-09-01後的檢測數據

{prefix}/fhir/Observation?patient=23&_lastUpdated=gt2024-09-01

獲取patient id 23於2024-09-01當天及之前的檢測數據

{prefix}/fhir/Observation?patient=23&_lastUpdated=le2024-09-01

獲取patient id 23於2024-09-01當天及之後的檢測數據

{prefix}/fhir/Observation?patient=23&_lastUpdated=ge2024-09-01

也可以獲取特定時間區段的測量數據

獲取patient id 23在2024-09-01到2024-09-15之間的檢測數據(不包含2024-09-01和2024-09-15當日)

{prefix}/fhir/Observation?patient=23&_lastUpdated=gt2024-09-01&_lastUpdated=lt2024-09-15

獲取patient id 23特定種類的測量數據

{prefix}/fhir/Observation?patient=23&_content={測量數據種類}
  • Blood%20pressure : 血壓
  • Heart%20rate : 心率
  • Glucose : 血糖
  • oxygen_saturation : 血氧
  • Body%20temperature : 體溫

註:可以一次查詢多種檢測數據,不同種類數據間以逗號隔開

範例

獲取patient id 23於2024-09-01當天的血壓檢測數據

{prefix}/fhir/Observation?patient=23&_lastUpdated=eq2024-09-01&_content=Blood%20pressure

獲取patient id 23於2024-09-01當天的血壓和血糖檢測數據

{prefix}/fhir/Observation?patient=23&_lastUpdated=eq2024-09-01&_content=Blood%20pressure,Glucose

獲取patient id 23特定種類測量數據的特定數值搜尋

{prefix}/fhir/Observation?patient=23&_content={測量數據種類}&value-quantity={搜尋的數值範圍}

範例

獲取patient id 23於2024-09-01當天體溫超過37.5度的檢測數據

{prefix}/fhir/Observation?patient=23&_lastUpdated=eq2024-09-01&_content=Body%20temperature&value-quantity=gt37.5
  • eq : 等於
  • gt : 大於
  • ge : 大於或等於
  • lt : 小於
  • le : 小於或等於

Tips

  • 可以藉由組合不同Request Parameter(參數)來獲取特定的搜尋結果,如_content=oxygen_saturation&value-quantity=lt90,可以搜尋出所有血氧低於90的測量數據,如果再增加參數,如_content=oxygen_saturation&value-quantity=lt90&_lastUpdated=gt2024-09-01&_lastUpdated=lt2024-09-15,就可以搜尋出在2024-09-01到2024-09-15之間所有血氧低於90的測量數據,可以依照需求調整Request Parameter

各測量數據範例

血壓範例

{
    "resourceType": "Observation",
    "id": "8",
    "meta": {
        "versionId": "1",
        "lastUpdated": "2024-09-01T06:38:14.556+00:00",
        "source": "#h7dsukROEewNVBhv",
        
    },
    
    "category": [
        {
            "coding": [
                {
                    "system": "http://terminology.hl7.org/CodeSystem/observation-category",
                    "code": "vital-signs",
                    "display": "Vital Signs"
                }
            ]
        },
        {
            "text": "Vital Signs"
        }
    ],
    "code": {
        "coding": [
            {
                "system": "http://loinc.org",
                "code": "85354-9",
                "display": "Blood pressure panel with all children optional"
            }
        ],
        "text": "Blood pressure systolic & diastolic"
    },
    "component": [
        {
            "code": {
                "coding": [
                    {
                        "system": "http://loinc.org",
                        "code": "8480-6",
                        "display": "Systolic blood pressure"
                    }
                ]
            },
            "valueQuantity": {
                "value": 136,
                "unit": "mmHg",
                "system": "http://unitsofmeasure.org",
                "code": "mm[Hg]"
            }
        },
        {
            "code": {
                "coding": [
                    {
                        "system": "http://loinc.org",
                        "code": "8462-4",
                        "display": "Diastolic blood pressure"
                    }
                ]
            },
            "valueQuantity": {
                "value": 96,
                "unit": "mmHg",
                "system": "http://unitsofmeasure.org",
                "code": "mm[Hg]"
            }
        }
    ]
}

心率範例

{
    "resourceType": "Observation",
    "id": "28",
    "meta": {
        "versionId": "1",
        "lastUpdated": "2024-09-01T08:39:04.541+00:00",
        "source": "#IzEiKEYCk8sSi0pf",
        
    },
   
    "category": [
        {
            "coding": [
                {
                    "system": "http://terminology.hl7.org/CodeSystem/observation-category",
                    "code": "vital-signs",
                    "display": "Vital Signs"
                }
            ]
        },
        {
            "text": "Vital Signs"
        }
    ],
    "code": {
        "coding": [
            {
                "system": "http://loinc.org",
                "code": "8867-4",
                "display": "Heart rate"
            }
        ],
        "text": "Heart rate"
    },
    "valueQuantity": {
        "value": 100,
        "unit": "beats/minute",
        "system": "http://unitsofmeasure.org",
        "code": "/min"
    }
}

血糖範例

{
    "resourceType": "Observation",
    "id": "33",
    "meta": {
        "versionId": "1",
        "lastUpdated": "2024-09-01T09:31:41.444+00:00",
        "source": "#DcaQT7lUmbHLbQJR",
        
    },
   
    "code": {
        "coding": [
            {
                "system": "http://loinc.org",
                "code": "15074-8",
                "display": "Glucose [Moles/volume] in Blood"
            }
        ],
        "text": "Glucose [Moles/volume] in Blood"
    },
    "valueQuantity": {
        "value": 3.2,
        "unit": "mmol/l",
        "system": "http://unitsofmeasure.org",
        "code": "mmol/L"
    }
}

血氧範例

{
    "resourceType": "Observation",
    "id": "40",
    "meta": {
        "versionId": "1",
        "lastUpdated": "2023-2024-09-01T07:44:53.245+00:00",
        "source": "#X7wEhCdW0dIOLBrz",
        
    },
    
    "category": [
        {
            "coding": [
                {
                    "system": "http://terminology.hl7.org/CodeSystem/observation-category",
                    "code": "vital-signs",
                    "display": "Vital Signs"
                }
            ]
        },
        {
            "text": "Vital Signs"
        }
    ],
    "code": {
        "coding": [
            {
                "system": "http://loinc.org",
                "code": "2708-6",
                "display": "Oxygen saturation in Arterial blood"
            },
            {
                "system": "http://loinc.org",
                "code": "59408-5",
                "display": "Oxygen saturation in Arterial blood by Pulse oximetry"
            }
        ],
        "text": "oxygen_saturation"
    },
    "valueQuantity": {
        "value": 99.0,
        "unit": "%O2",
        "system": "http://unitsofmeasure.org",
        "code": "%"
    }
}

體溫範例

{
    "resourceType": "Observation",
    "id": "54",
    "meta": {
        "versionId": "1",
        "lastUpdated": "2024-09-01T08:33:02.252+00:00",
        "source": "#xEtU1b3aEZaMWdgl",

    },

    "category": [
        {
            "coding": [
                {
                    "system": "http://terminology.hl7.org/CodeSystem/observation-category",
                    "code": "vital-signs",
                    "display": "Vital Signs"
                }
            ]
        },
        {
            "text": "Vital Signs"
        }
    ],
    "code": {
        "coding": [
            {
                "system": "http://loinc.org",
                "code": "8310-5",
                "display": "Body temperature"
            }
        ],
        "text": "Body temperature"
    },
    "valueQuantity": {
        "value": 39.1,
        "unit": "C",
        "system": "http://unitsofmeasure.org",
        "code": "Cel"
    }
}

以上是各種常見的Observation範例及一些常用的FHIR API 規則,主要圍繞在Patient和Observation上。可以調換不同的Resource進行查詢檢索,如以Patient為查詢主體,Organization為檢索條件,搜尋出某一個Organization內全部的病患。還有更多其他有用的API規則,若需要使用可以再到HL7官網查詢。


上一篇
Day 4 [數位醫療] HAPI Server初體驗!
下一篇
Day 6 [數位醫療] FHIR Server (HAPI Server) 建置( Intellij IDEA)
系列文
數位醫療與雲原生第一次的親密接觸30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言